package sigeco.model;

import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.validator.NotNull;

/**
 * KnowledgeGroup class.
 * 
 * A KnowledgeGroup is an entity that has a name, may have nested (children)
 * KnowledgeGroups and may have Knowledges.
 * 
 * Its purpose is to group Knowledges in categories and sub-categories.
 * 
 * @author julien
 *
 */
@Entity
@Table(name = "knowledge_groups")
public class KnowledgeGroup {

	private Matrix matrix;
	private KnowledgeGroup parent;
	private Set<KnowledgeGroup> children;
	private Set<Knowledge> knowledges;
	private long id;

	@NotNull
	@ManyToOne
	public Matrix getMatrix() {
		return this.matrix;
	}

	public void setMatrix(final Matrix matrix) {
		this.matrix = matrix;
	}

	@ManyToOne
	public KnowledgeGroup getParent() {
		return this.parent;
	}

	public void setParent(final KnowledgeGroup parent) {
		this.parent = parent;
	}

	@OneToMany(targetEntity = KnowledgeGroup.class, mappedBy = "parent")
	public Set<KnowledgeGroup> getChildren() {
		return this.children;
	}

	public void setChildren(final Set<KnowledgeGroup> children) {
		this.children = children;
	}

	@OneToMany(targetEntity = Knowledge.class, mappedBy = "knowledgeGroup")
	@NotNull
	public Set<Knowledge> getKnowledges() {
		return knowledges;
	}

	public void setKnowledges(Set<Knowledge> knowledges) {
		this.knowledges = knowledges;
	}
	
	@Id
	@GeneratedValue
	public long getId() {
		return this.id;
	}

	public void setId(final long id) {
		this.id = id;
	}
	
}
